Produced by Araxis Merge on 2022-11-18 03:12:06 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Porto Theme/app/code/Smartwave/Porto/Helper | Data.php | 2022-09-07 04:05:16 +0000 |
| 2 | Theme Files/Magento 2.x/Porto Theme/app/code/Smartwave/Porto/Helper | Data.php | 2022-09-28 10:45:42 +0000 |
| Description | Between Files 1 and 2 | |
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 380 |
| Changed | 0 | 0 |
| Inserted | 1 | 25 |
| Removed | 0 | 0 |
| Whitespace | Consecutive whitespace is treated as a single space |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
| Active line-pairing rules |
No regular expressions were active.
| 1 | <?php | 1 | <?php | |||
| 2 | /** | 2 | /** | |||
| 3 | * Copyright © 2015 Magento. All rights reserved. | 3 | * Copyright © 2015 Magento. All rights reserved. | |||
| 4 | * See COPYING.txt for license details. | 4 | * See COPYING.txt for license details. | |||
| 5 | */ | 5 | */ | |||
| 6 | namespace Smartwave\Porto\Helper; | 6 | namespace Smartwave\Porto\Helper; | |||
| 7 | 7 | |||||
| 8 | use Magento\Framework\Registry; | 8 | use Magento\Framework\Registry; | |||
| 9 | 9 | |||||
| 10 | class Data extends \Magento\Framework\App\Helper\AbstractHelper | 10 | class Data extends \Magento\Framework\App\Helper\AbstractHelper | |||
| 11 | { | 11 | { | |||
| 12 | 12 | |||||
| 13 | protected $_objectManager; | 13 | protected $_objectManager; | |||
| 14 | private $_registry; | 14 | private $_registry; | |||
| 15 | protected $_filterProvider; | 15 | protected $_filterProvider; | |||
| 16 | private $_checkedPurchaseCode; | 16 | private $_checkedPurchaseCode; | |||
| 17 | private $_messageManager; | 17 | private $_messageManager; | |||
| 18 | protected $_configFactory; | 18 | protected $_configFactory; | |||
| 19 | 19 | |||||
| 20 | public function __construct( | 20 | public function __construct( | |||
| 21 | \Magento\Framework\App\Helper\Context $context, | 21 | \Magento\Framework\App\Helper\Context $context, | |||
| 22 | \Magento\Framework\ObjectManagerInterface $objectManager, | 22 | \Magento\Framework\ObjectManagerInterface $objectManager, | |||
| 23 | \Magento\Store\Model\StoreManagerInterface $storeManager, | 23 | \Magento\Store\Model\StoreManagerInterface $storeManager, | |||
| 24 | \Magento\Cms\Model\Template\FilterProvider $filterProvider, | 24 | \Magento\Cms\Model\Template\FilterProvider $filterProvider, | |||
| 25 | \Magento\Framework\Message\ManagerInterface $messageManager, | 25 | \Magento\Framework\Message\ManagerInterface $messageManager, | |||
| 26 | \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configFactory, | 26 | \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configFactory, | |||
| 27 | Registry $registry | 27 | Registry $registry | |||
| 28 | ) { | 28 | ) { | |||
| 29 | $this->_storeManager = $storeManager; | 29 | $this->_storeManager = $storeManager; | |||
| 30 | $this->_objectManager = $objectManager; | 30 | $this->_objectManager = $objectManager; | |||
| 31 | $this->_filterProvider = $filterProvider; | 31 | $this->_filterProvider = $filterProvider; | |||
| 32 | $this->_registry = $registry; | 32 | $this->_registry = $registry; | |||
| 33 | $this->_messageManager = $messageManager; | 33 | $this->_messageManager = $messageManager; | |||
| 34 | $this->_configFactory = $configFactory; | 34 | $this->_configFactory = $configFactory; | |||
| 35 | 35 | |||||
| 36 | parent::__construct($context); | 36 | parent::__construct($context); | |||
| 37 | } | 37 | } | |||
| 38 | public function checkPurchaseCode($save = false) { | 38 | public function checkPurchaseCode($save = false) { | |||
| 39 | if($this->isLocalhost()){ | 39 | if($this->isLocalhost()){ | |||
| 40 | return "localhost"; | 40 | return "localhost"; | |||
| 41 | } | 41 | } | |||
| 42 | if(!$this->_checkedPurchaseCode){ | 42 | if(!$this->_checkedPurchaseCode){ | |||
| 43 | $code = $this->scopeConfig->getValue('porto_license/general/purchase_code')?$this->scopeConfig->getValue('porto_license/general/purchase_code'):''; | 43 | $code = $this->scopeConfig->getValue('porto_license/general/purchase_code')?$this->scopeConfig->getValue('porto_license/general/purchase_code'):''; | |||
| 44 | $code_confirm = $this->scopeConfig->getValue('porto_license/general/purchase_code_confirm')?$this->scopeConfig->getValue('porto_license/general/purchase_code_confirm'):''; | 44 | $code_confirm = $this->scopeConfig->getValue('porto_license/general/purchase_code_confirm')?$this->scopeConfig->getValue('porto_license/general/purchase_code_confirm'):''; | |||
| 45 | 45 | |||||
| 46 | if($save) { | 46 | if($save) { | |||
| 47 | $site_url = $this->scopeConfig->getValue('web/unsecure/base_url'); | 47 | $site_url = $this->scopeConfig->getValue('web/unsecure/base_url'); | |||
| 48 | $domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $site_url)); | 48 | $domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $site_url)); | |||
| 49 | if(strpos($domain, "/")) | 49 | if(strpos($domain, "/")) | |||
| 50 | $domain = substr($domain, 0, strpos($domain, "/")); | 50 | $domain = substr($domain, 0, strpos($domain, "/")); | |||
| 51 | if(!$code || base64_encode($code) != $code_confirm) { | 51 | if(!$code || base64_encode($code) != $code_confirm) { | |||
| 52 | $this->curlPurchaseCode(base64_decode($code_confirm), "", "remove"); | 52 | $this->curlPurchaseCode(base64_decode($code_confirm), "", "remove"); | |||
| 53 | } | 53 | } | |||
| 54 | if($code) { | 54 | if($code) { | |||
| 55 | $result = $this->curlPurchaseCode($code, $domain, "add"); | 55 | $result = $this->curlPurchaseCode($code, $domain, "add"); | |||
| 56 | if(!$result || $result['result'] == 0) { | 56 | if(!$result || $result['result'] == 0) { | |||
| 57 | $this->_checkedPurchaseCode = ""; | 57 | $this->_checkedPurchaseCode = ""; | |||
| 58 | $code_confirm = ""; | 58 | $code_confirm = ""; | |||
| 59 | $this->_messageManager->getMessages(true); | 59 | $this->_messageManager->getMessages(true); | |||
| 60 | $this->_messageManager->addWarning(__('Purchase code is not valid!')); | 60 | $this->_messageManager->addWarning(__('Purchase code is not valid!')); | |||
| 61 | } else if($result['result'] == 1) { | 61 | } else if($result['result'] == 1) { | |||
| 62 | $code_confirm = base64_encode($code); | 62 | $code_confirm = base64_encode($code); | |||
| 63 | $this->_checkedPurchaseCode = "verified"; | 63 | $this->_checkedPurchaseCode = "verified"; | |||
| 64 | } else { | 64 | } else { | |||
| 65 | $this->_checkedPurchaseCode = ""; | 65 | $this->_checkedPurchaseCode = ""; | |||
| 66 | $code_confirm = ""; | 66 | $code_confirm = ""; | |||
| 67 | $this->_messageManager->getMessages(true); | 67 | $this->_messageManager->getMessages(true); | |||
| 68 | $this->_messageManager->addWarning(__($result['message'])); | 68 | $this->_messageManager->addWarning(__($result['message'])); | |||
| 69 | } | 69 | } | |||
| 70 | } else { | 70 | } else { | |||
| 71 | $code_confirm = ""; | 71 | $code_confirm = ""; | |||
| 72 | $this->_checkedPurchaseCode = ""; | 72 | $this->_checkedPurchaseCode = ""; | |||
| 73 | } | 73 | } | |||
| 74 | $this->_configFactory->saveConfig('porto_license/general/purchase_code_confirm',$code_confirm,"default",0); | 74 | $this->_configFactory->saveConfig('porto_license/general/purchase_code_confirm',$code_confirm,"default",0); | |||
| 75 | } else { | 75 | } else { | |||
| 76 | if($code && $code_confirm && base64_encode($code) == $code_confirm) | 76 | if($code && $code_confirm && base64_encode($code) == $code_confirm) | |||
| 77 | $this->_checkedPurchaseCode = "verified"; | 77 | $this->_checkedPurchaseCode = "verified"; | |||
| 78 | } | 78 | } | |||
| 79 | } | 79 | } | |||
| 80 | 80 | |||||
| 81 | return $this->_checkedPurchaseCode; | 81 | return $this->_checkedPurchaseCode; | |||
| 82 | } | 82 | } | |||
| 83 | public function curlPurchaseCode($code, $domain, $act) { | 83 | public function curlPurchaseCode($code, $domain, $act) { | |||
| 84 | $ch = curl_init(); | 84 | $ch = curl_init(); | |||
| 85 | 85 | |||||
| 86 | // Set cURL options | 86 | // Set cURL options | |||
| 87 | curl_setopt($ch, CURLOPT_URL, "http://www.portotheme.com/envato/verify_purchase_new.php?item=9725864&version=m2&code=$code&domain=$domain&act=$act"); | 87 | curl_setopt($ch, CURLOPT_URL, "http://www.portotheme.com/envato/verify_purchase_new.php?item=9725864&version=m2&code=$code&domain=$domain&act=$act"); | |||
| 88 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | 88 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |||
| 89 | curl_setopt($ch, CURLOPT_USERAGENT, 'PORTO-PURCHASE-VERIFY'); | 89 | curl_setopt($ch, CURLOPT_USERAGENT, 'PORTO-PURCHASE-VERIFY'); | |||
| 90 | 90 | |||||
| 91 | // Decode returned JSON | 91 | // Decode returned JSON | |||
| 92 | $result = json_decode( curl_exec($ch) , true ); | 92 | $result = json_decode( curl_exec($ch) , true ); | |||
| 93 | return $result; | 93 | return $result; | |||
| 94 | } | 94 | } | |||
| 95 | public function isLocalhost() { | 95 | public function isLocalhost() { | |||
| 96 | $whitelist = array( | 96 | $whitelist = array( | |||
| 97 | '127.0.0.1', | 97 | '127.0.0.1', | |||
| 98 | '::1' | 98 | '::1' | |||
| 99 | ); | 99 | ); | |||
| 100 | 100 | |||||
| 101 | return in_array($_SERVER['REMOTE_ADDR'], $whitelist); | 101 | return in_array($_SERVER['REMOTE_ADDR'], $whitelist); | |||
| 102 | } | 102 | } | |||
| 103 | public function isAdmin() { | 103 | public function isAdmin() { | |||
| 104 | $om = \Magento\Framework\App\ObjectManager::getInstance(); | 104 | $om = \Magento\Framework\App\ObjectManager::getInstance(); | |||
| 105 | $app_state = $om->get('\Magento\Framework\App\State'); | 105 | $app_state = $om->get('\Magento\Framework\App\State'); | |||
| 106 | $area_code = $app_state->getAreaCode(); | 106 | $area_code = $app_state->getAreaCode(); | |||
| 107 | if($area_code == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) | 107 | if($area_code == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) | |||
| 108 | { | 108 | { | |||
| 109 | return true; | 109 | return true; | |||
| 110 | } | 110 | } | |||
| 111 | else | 111 | else | |||
| 112 | { | 112 | { | |||
| 113 | return false; | 113 | return false; | |||
| 114 | } | 114 | } | |||
| 115 | } | 115 | } | |||
| 116 | public function getBaseUrl() | 116 | public function getBaseUrl() | |||
| 117 | { | 117 | { | |||
| 118 | return $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); | 118 | return $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); | |||
| 119 | } | 119 | } | |||
| 120 | public function getBaseLinkUrl() | 120 | public function getBaseLinkUrl() | |||
| 121 | { | 121 | { | |||
| 122 | return $this->_storeManager->getStore()->getBaseUrl(); | 122 | return $this->_storeManager->getStore()->getBaseUrl(); | |||
| 123 | } | 123 | } | |||
| 124 | public function getConfig($config_path) | 124 | public function getConfig($config_path) | |||
| 125 | { | 125 | { | |||
| 126 | return $this->scopeConfig->getValue( | 126 | return $this->scopeConfig->getValue( | |||
| 127 | $config_path, | 127 | $config_path, | |||
| 128 | \Magento\Store\Model\ScopeInterface::SCOPE_STORE | 128 | \Magento\Store\Model\ScopeInterface::SCOPE_STORE | |||
| 129 | ); | 129 | ); | |||
| 130 | } | 130 | } | |||
| 131 | public function getModel($model) { | 131 | public function getModel($model) { | |||
| 132 | return $this->_objectManager->create($model); | 132 | return $this->_objectManager->create($model); | |||
| 133 | } | 133 | } | |||
| 134 | public function getCurrentStore() { | 134 | public function getCurrentStore() { | |||
| 135 | return $this->_storeManager->getStore(); | 135 | return $this->_storeManager->getStore(); | |||
| 136 | } | 136 | } | |||
| 137 | public function filterContent($content) { | 137 | public function filterContent($content) { | |||
| 138 | return $this->_filterProvider->getPageFilter()->filter($content); | 138 | return $this->_filterProvider->getPageFilter()->filter($content); | |||
| 139 | } | 139 | } | |||
| 140 | public function getCategoryProductIds($current_category) { | 140 | public function getCategoryProductIds($current_category) { | |||
| 141 | $category_products = $current_category->getProductCollection() | 141 | $category_products = $current_category->getProductCollection() | |||
| 142 | ->addAttributeToSelect('*') | 142 | ->addAttributeToSelect('*') | |||
| 143 | ->addAttributeToSort('position','asc'); | 143 | ->addAttributeToSort('position','asc'); | |||
| 144 | $cat_prod_ids = $category_products->getAllIds(); | 144 | $cat_prod_ids = $category_products->getAllIds(); | |||
| 145 | 145 | |||||
| 146 | return $cat_prod_ids; | 146 | return $cat_prod_ids; | |||
| 147 | } | 147 | } | |||
| 148 | public function getPercentage(\Magento\Catalog\Model\Product $product) | |||||
| 149 | { | |||||
| 150 | $baseprice = 0; | |||||
| 151 | $finalprice = 0; | |||||
| 152 | $percentage = 0; | |||||
| 153 | ||||||
| 154 | if ($product->getTypeId() == 'configurable') { | |||||
| 155 | $baseprice = $product->getPriceInfo() | |||||
| 156 | ->getPrice('regular_price') | |||||
| 157 | ->getValue(); | |||||
| 158 | ||||||
| 159 | $finalprice = $product->getPriceInfo() | |||||
| 160 | ->getPrice('final_price') | |||||
| 161 | ->getValue(); | |||||
| 162 | } else { | |||||
| 163 | $baseprice = $product->getPrice(); | |||||
| 164 | $finalprice = $product->getFinalPrice(); | |||||
| 165 | } | |||||
| 166 | ||||||
| 167 | if ($finalprice < $baseprice) { | |||||
| 168 | $percentage = round(-100 * (1 - ($finalprice / $baseprice))); | |||||
| 169 | } | |||||
| 170 | ||||||
| 171 | return $percentage; | |||||
| 172 | } | |||||
| 148 | public function getPrevProduct($product) { | 173 | public function getPrevProduct($product) { | |||
| 149 | $current_category = $product->getCategory(); | 174 | $current_category = $product->getCategory(); | |||
| 150 | if(!$current_category) { | 175 | if(!$current_category) { | |||
| 151 | foreach($product->getCategoryCollection() as $parent_cat) { | 176 | foreach($product->getCategoryCollection() as $parent_cat) { | |||
| 152 | $current_category = $parent_cat; | 177 | $current_category = $parent_cat; | |||
| 153 | } | 178 | } | |||
| 154 | } | 179 | } | |||
| 155 | if(!$current_category) | 180 | if(!$current_category) | |||
| 156 | return false; | 181 | return false; | |||
| 157 | $cat_prod_ids = $this->getCategoryProductIds($current_category); | 182 | $cat_prod_ids = $this->getCategoryProductIds($current_category); | |||
| 158 | $_pos = array_search($product->getId(), $cat_prod_ids); | 183 | $_pos = array_search($product->getId(), $cat_prod_ids); | |||
| 159 | if (isset($cat_prod_ids[$_pos - 1])) { | 184 | if (isset($cat_prod_ids[$_pos - 1])) { | |||
| 160 | $prev_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos - 1]); | 185 | $prev_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos - 1]); | |||
| 161 | return $prev_product; | 186 | return $prev_product; | |||
| 162 | } | 187 | } | |||
| 163 | return false; | 188 | return false; | |||
| 164 | } | 189 | } | |||
| 165 | public function getNextProduct($product) { | 190 | public function getNextProduct($product) { | |||
| 166 | $current_category = $product->getCategory(); | 191 | $current_category = $product->getCategory(); | |||
| 167 | if(!$current_category) { | 192 | if(!$current_category) { | |||
| 168 | foreach($product->getCategoryCollection() as $parent_cat) { | 193 | foreach($product->getCategoryCollection() as $parent_cat) { | |||
| 169 | $current_category = $parent_cat; | 194 | $current_category = $parent_cat; | |||
| 170 | } | 195 | } | |||
| 171 | } | 196 | } | |||
| 172 | if(!$current_category) | 197 | if(!$current_category) | |||
| 173 | return false; | 198 | return false; | |||
| 174 | $cat_prod_ids = $this->getCategoryProductIds($current_category); | 199 | $cat_prod_ids = $this->getCategoryProductIds($current_category); | |||
| 175 | $_pos = array_search($product->getId(), $cat_prod_ids); | 200 | $_pos = array_search($product->getId(), $cat_prod_ids); | |||
| 176 | if (isset($cat_prod_ids[$_pos + 1])) { | 201 | if (isset($cat_prod_ids[$_pos + 1])) { | |||
| 177 | $next_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos + 1]); | 202 | $next_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos + 1]); | |||
| 178 | return $next_product; | 203 | return $next_product; | |||
| 179 | } | 204 | } | |||
| 180 | return false; | 205 | return false; | |||
| 181 | } | 206 | } | |||
| 182 | 207 | |||||
| 183 | public function getMasonryItemClass($arr) { | 208 | public function getMasonryItemClass($arr) { | |||
| 184 | $item_class = ""; | 209 | $item_class = ""; | |||
| 185 | foreach ($arr as $key => $value) { | 210 | foreach ($arr as $key => $value) { | |||
| 186 | $item_class .= ' ' . $key . '-' . $value; | 211 | $item_class .= ' ' . $key . '-' . $value; | |||
| 187 | } | 212 | } | |||
| 188 | return $item_class; | 213 | return $item_class; | |||
| 189 | } | 214 | } | |||
| 190 | } | 215 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993–2019 Araxis Ltd (www.araxis.com). All rights reserved.